<?php
namespace app\erp_meixingtiyu\controller;

use think\facade\Request;
use app\store\controller\Controller as StoreController;
use app\erp_meixingtiyu\logic\MemberCard as MemberCardLogic;

class MemberCard extends StoreController
{
    public function all()
    {
        $list = (new MemberCardLogic())->getCartByPaginate();
        return $this->renderSuccess($list);
    }

    public function add()
    {
        $params = Request::only([
            'name',
            'status',
            'price',
            'introduce',
            'use_rules',
            'recommend',
            'type',
            'limite',
            'image_id',
            'effective',
            'sort',
        ]);

        $card = (new MemberCardLogic())->addCard($params);
        return $this->renderSuccess($card, '添加成功');
    }

    public function delete($cardId)
    {
        (new MemberCardLogic())->deleteCard($cardId);
        return $this->renderSuccess('删除成功');
    }

    public function edit()
    {
        $params = Request::only([
            'nid',
            'name',
            'status',
            'price',
            'use_rules',
            'introduce',
            'recommend',
            'type',
            'limite',
            'image_id',
            'effective',
            'sort',
        ]);

        MemberCardLogic::editCard($params);
        return $this->renderSuccess('编辑成功');
    }

    // 获取会员卡订单列表
    public function orderList()
    {
        $list = (new MemberCardLogic())->getOrderList();
        return $this->renderSuccess($list);
    }

    // 根据日期获取会员卡订单列表
    public function orderListFilter($dateArr)
    {
        $list = (new MemberCardLogic())->getOrderListByDate($dateArr);
        return $this->renderSuccess($list);
    }
}
